From 92b4a139ba7eb9f937f7315fb05c54f8b5982d06 Mon Sep 17 00:00:00 2001 From: GMT 2000 Tony Gale Date: Tue, 22 Feb 2000 13:49:53 +0000 Subject: [PATCH] FAQ Update Tue Feb 22 13:54:12 GMT 2000 Tony Gale * docs/gtkfaq.sgml: FAQ Update --- ChangeLog | 4 + ChangeLog.pre-2-0 | 4 + ChangeLog.pre-2-10 | 4 + ChangeLog.pre-2-2 | 4 + ChangeLog.pre-2-4 | 4 + ChangeLog.pre-2-6 | 4 + ChangeLog.pre-2-8 | 4 + docs/faq/gtkfaq.sgml | 247 +++++++++++++++++++++++++++++++++---------- docs/gtkfaq.sgml | 247 +++++++++++++++++++++++++++++++++---------- 9 files changed, 410 insertions(+), 112 deletions(-) diff --git a/ChangeLog b/ChangeLog index 708b9ff575..0ff5f0636a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Tue Feb 22 13:54:12 GMT 2000 Tony Gale + + * docs/gtkfaq.sgml: FAQ Update + 2000-02-19 Anders Carlsson * gtk/gtkrange.c (gtk_range_scroll_event): Return TRUE diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 708b9ff575..0ff5f0636a 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,7 @@ +Tue Feb 22 13:54:12 GMT 2000 Tony Gale + + * docs/gtkfaq.sgml: FAQ Update + 2000-02-19 Anders Carlsson * gtk/gtkrange.c (gtk_range_scroll_event): Return TRUE diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 708b9ff575..0ff5f0636a 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,7 @@ +Tue Feb 22 13:54:12 GMT 2000 Tony Gale + + * docs/gtkfaq.sgml: FAQ Update + 2000-02-19 Anders Carlsson * gtk/gtkrange.c (gtk_range_scroll_event): Return TRUE diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 708b9ff575..0ff5f0636a 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,7 @@ +Tue Feb 22 13:54:12 GMT 2000 Tony Gale + + * docs/gtkfaq.sgml: FAQ Update + 2000-02-19 Anders Carlsson * gtk/gtkrange.c (gtk_range_scroll_event): Return TRUE diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 708b9ff575..0ff5f0636a 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,7 @@ +Tue Feb 22 13:54:12 GMT 2000 Tony Gale + + * docs/gtkfaq.sgml: FAQ Update + 2000-02-19 Anders Carlsson * gtk/gtkrange.c (gtk_range_scroll_event): Return TRUE diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 708b9ff575..0ff5f0636a 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,7 @@ +Tue Feb 22 13:54:12 GMT 2000 Tony Gale + + * docs/gtkfaq.sgml: FAQ Update + 2000-02-19 Anders Carlsson * gtk/gtkrange.c (gtk_range_scroll_event): Return TRUE diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 708b9ff575..0ff5f0636a 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,7 @@ +Tue Feb 22 13:54:12 GMT 2000 Tony Gale + + * docs/gtkfaq.sgml: FAQ Update + 2000-02-19 Anders Carlsson * gtk/gtkrange.c (gtk_range_scroll_event): Return TRUE diff --git a/docs/faq/gtkfaq.sgml b/docs/faq/gtkfaq.sgml index 1dea1a6c26..9ec3927ea3 100644 --- a/docs/faq/gtkfaq.sgml +++ b/docs/faq/gtkfaq.sgml @@ -9,7 +9,7 @@ Tony Gale, Shawn T. Amundson, Emmanuel Deloget, Nathan Froyd -November 9th 1999 +February 9th 2000 This document is intended to answer questions that are likely to be frequently asked by programmers using GTK+ or people who are just looking at @@ -1477,6 +1477,19 @@ Moreover, Havoc posted this to the + +Data I pass to the +All event handlers take an additional argument which contains +information about the event that triggered the handler. So, a + +gint delete_event_handler (GtkWidget *widget, + GdkEventAny *event, + gpointer data); + + I have my signal connected to the the (whatever) event, but it seems I don't catch it. What's wrong?

@@ -1544,7 +1557,7 @@ placed on a queue, which is processed within -while (g_main_iteration(FALSE)); +while (gtk_main_iteration(FALSE)); inside you're function that changes the widget. @@ -1606,6 +1619,36 @@ you: replace the data with NULL (with the same key) + +How do I reparent a widget? +

+The normal way to reparent (ie change the owner) of a widget should be +to use the function: + + +void gtk_widget_reparent (GtkWidget *widget, + GtkWidget *new_parent) + + +But this is only a "should be" since this function does not correctly +do its job on some specific widgets. The main goal of +gtk_widget_reparent() is to avoid unrealizing widget if both widget +and new_parent are realized (in this case, widget->window is +successfully reparented). The problem here is that some widgets in the +GTK+ hierarchy have multiple attached X subwindows and this is notably +the case for the GtkSpinButton widget. For those, +gtk_widget_reparent() will fail by leaving an unrealized child window +where it should not. + +To avoid this problem, simply use the following code snippet: + + + gtk_widget_ref(widget); + gtk_container_remove(GTK_CONTAINER(old_parent), widget); + gtk_container_add(GTK_CONTAINER(new_parent), widget); + gtk_widget_unref(widget); + + How could I get any widgets position?

@@ -1613,15 +1656,26 @@ As Tim Janik pointed out, there are different cases, and each case requires a different solution. - If you want the position of a widget relative to its parent, you should - use allocation.x/ and allocation.y/. - If you want the position of a window relative to the X root window, - you should use If you want the position of a widget relative to its parent, + you should use allocation.x/ and + allocation.y/. + If you want the position of a window relative to the X root + window, you should use Last but not least, if you want to get a Window Manager frame position, - you should use If you want to get the position of the window (including the WM + decorations), you should use + Last but not least, if you want to get a Window Manager frame + position, you should use + +Your choice of Window Manager will have an effect of the results of +the above functions. You should keep this in mind when writing your +application. This is dependant upon how the Window Managers manage the +decorations that they add around windows. + How do I set the size of a widget/window? How do I prevent the user resizing my window?

@@ -1632,17 +1686,17 @@ The -void gtk_widget_set_usize (GtkWidget *widget, - gint width, - gint height); - -void gtk_window_set_policy (GtkWindow *window, - gint allow_shrink, - gint allow_grow, - gint auto_shrink); +void gtk_widget_set_usize (GtkWidget *widget, + gint width, + gint height); + +void gtk_window_set_policy (GtkWindow *window, + gint allow_shrink, + gint allow_grow, + gint auto_shrink); +The window, + x_pos, y_pos, + x_size, y_size); How do I add a popup menu to my GTK+ application?

@@ -1694,8 +1762,8 @@ is a boolean value: when this value is TRUE, the widget is enabled.

For example: -gint gtk_clist_prepend (GtkCList *clist, - gchar *text[]); +gint gtk_clist_prepend (GtkCList *clist, + gchar *text[]); Answer: No, while a type "gchar*" (pointer to char) can automatically @@ -1730,6 +1798,34 @@ DirectMedia Layer library (SDL). You do NOT want to use +How do I create a pixmap without having my window realized/shown? +

+Functions such as + char *pixfile = "foo.xpm"; + GtkWidget *top, *box, *pixw; + GdkPixmap *pixmap, *pixmap_mask; + + top = gtk_window_new (GKT_WINDOW_TOPLEVEL); + box = gtk_hbox_new (FALSE, 4); + gtk_conainer_add (GTK_CONTAINER(top), box); + + pixmap = gdk_pixmap_colormap_create_from_xpm ( + NULL, gtk_widget_get_colormap(top), + &pixmap_mask, NULL, pixfile); + pixw = gtk_pixmap_new (pixmap, pixmap_mask); + gdk_pixmap_unref (pixmap); + gdk_pixmap_unref (pixmap_mask); + + + Development with GTK+: widget specific questions @@ -1836,6 +1932,25 @@ To get known about the selection: } + +How do I stop the column headings of a GtkCList disappearing +when the list is scrolled? +

+This happens when a GtkCList is packed into a GtkScrolledWindow using +the function + GtkWidget *scrolled, *clist; + char *titles[] = { "Title1" , "Title2" }; + + scrolled = gtk_scrolled_window_new(NULL, NULL); + + clist = gtk_clist_new_with_titles(2, titles); + gtk_container_add(GTK_CONTAINER(scrolled), clist); + +

I don't want the user of my applications to enter text into a GtkCombo. Any idea?

@@ -1956,9 +2071,9 @@ align it, center it or left align it. If you want to do this, you should use: -void gtk_misc_set_alignment (GtkMisc *misc, - gfloat xalign, - gfloat yalign); +void gtk_misc_set_alignment (GtkMisc *misc, + gfloat xalign, + gfloat yalign); where the - -How do I use horizontal scrollbars with a GtkText widget? -

-The short answer is that you can't. The current version of the GtkText -widget does not support horizontal scrolling. There is an intention to -completely rewrite the GtkText widget, at which time this limitation -will be removed. - I can't add more than (something like) 2000 chars in a GtkEntry. What's wrong?

@@ -2064,6 +2171,28 @@ the number of chars in the entry to 2047. max_length = MIN (2047, entry->text_max_length); + +How do I make a GtkEntry widget activate on pressing the Return key? +

+The Entry widget emits an 'activate' signal when you press return in +it. Just attach to the activate signal on the entry and do whatever you +want to do. Typical code would be: + + + entry = gtk_entry_new(); + gtk_signal_connect (GTK_OBJECT(entry), "activate", + GTK_SIGNAL_FUNC(entry_callback), + NULL); + + + +How do I use horizontal scrollbars with a GtkText widget? +

+The short answer is that you can't. The current version of the GtkText +widget does not support horizontal scrolling. There is an intention to +completely rewrite the GtkText widget, at which time this limitation +will be removed. + How do I change the font of a GtkText widget?

@@ -2565,45 +2694,51 @@ have not accepted "hi 7 am 17" or "hi i hi 17". GTK+ FAQ Contributions, Maintainers and Copyright

-If you would like to make a contribution to the FAQ, send either one of us -an e-mail message with the exact text you think should be included (question and -answer). With your help, this document can grow and become more useful! +If you would like to make a contribution to the FAQ, send either one +of us an e-mail message with the exact text you think should be +included (question and answer). With your help, this document can grow +and become more useful! -This document is maintained by Nathan Froyd -, +This document is maintained by Tony Gale and +name="<gale@gtk.org>"> +Nathan Froyd , +and Emmanuel Deloget . This FAQ was created by Shawn T. Amundson who continues to provide support. -The GTK+ FAQ is Copyright (C) 1997,1998, 1999 by Shawn T. Amundson, -Nathan Froyd and Tony Gale, Emmanuel Deloget. +Contributions should be sent to Tony Gale + +The GTK+ FAQ is Copyright (C) 1997-2000 by Shawn T. Amundson, +Tony Gale, Emmanuel Deloget and Nathan Froyd. -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. +Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. -Permission is granted to copy and distribute modified versions of -this document under the conditions for verbatim copying, provided -that this copyright notice is included exactly as in the original, -and that the entire resulting derived work is distributed under -the terms of a permission notice identical to this one. +Permission is granted to copy and distribute modified versions of this +document under the conditions for verbatim copying, provided that this +copyright notice is included exactly as in the original, and that the +entire resulting derived work is distributed under the terms of a +permission notice identical to this one. -Permission is granted to copy and distribute translations of -this document into another language, under the above conditions -for modified versions. +Permission is granted to copy and distribute translations of this +document into another language, under the above conditions for +modified versions. -If you are intending to incorporate this document into a published work, -please contact one of the maintainers, and we will make an effort to ensure -that you have the most up to date information available. +If you are intending to incorporate this document into a published +work, please contact one of the maintainers, and we will make an +effort to ensure that you have the most up to date information +available. There is no guarentee that this document lives up to its intended -purpose. This is simply provided as a free resource. As such, -the authors and maintainers of the information provided within can -not make any guarentee that the information is even accurate. +purpose. This is simply provided as a free resource. As such, the +authors and maintainers of the information provided within can not +make any guarentee that the information is even accurate. diff --git a/docs/gtkfaq.sgml b/docs/gtkfaq.sgml index 1dea1a6c26..9ec3927ea3 100644 --- a/docs/gtkfaq.sgml +++ b/docs/gtkfaq.sgml @@ -9,7 +9,7 @@ Tony Gale, Shawn T. Amundson, Emmanuel Deloget, Nathan Froyd -November 9th 1999 +February 9th 2000 This document is intended to answer questions that are likely to be frequently asked by programmers using GTK+ or people who are just looking at @@ -1477,6 +1477,19 @@ Moreover, Havoc posted this to the + +Data I pass to the +All event handlers take an additional argument which contains +information about the event that triggered the handler. So, a + +gint delete_event_handler (GtkWidget *widget, + GdkEventAny *event, + gpointer data); + + I have my signal connected to the the (whatever) event, but it seems I don't catch it. What's wrong?

@@ -1544,7 +1557,7 @@ placed on a queue, which is processed within -while (g_main_iteration(FALSE)); +while (gtk_main_iteration(FALSE)); inside you're function that changes the widget. @@ -1606,6 +1619,36 @@ you: replace the data with NULL (with the same key) + +How do I reparent a widget? +

+The normal way to reparent (ie change the owner) of a widget should be +to use the function: + + +void gtk_widget_reparent (GtkWidget *widget, + GtkWidget *new_parent) + + +But this is only a "should be" since this function does not correctly +do its job on some specific widgets. The main goal of +gtk_widget_reparent() is to avoid unrealizing widget if both widget +and new_parent are realized (in this case, widget->window is +successfully reparented). The problem here is that some widgets in the +GTK+ hierarchy have multiple attached X subwindows and this is notably +the case for the GtkSpinButton widget. For those, +gtk_widget_reparent() will fail by leaving an unrealized child window +where it should not. + +To avoid this problem, simply use the following code snippet: + + + gtk_widget_ref(widget); + gtk_container_remove(GTK_CONTAINER(old_parent), widget); + gtk_container_add(GTK_CONTAINER(new_parent), widget); + gtk_widget_unref(widget); + + How could I get any widgets position?

@@ -1613,15 +1656,26 @@ As Tim Janik pointed out, there are different cases, and each case requires a different solution. - If you want the position of a widget relative to its parent, you should - use allocation.x/ and allocation.y/. - If you want the position of a window relative to the X root window, - you should use If you want the position of a widget relative to its parent, + you should use allocation.x/ and + allocation.y/. + If you want the position of a window relative to the X root + window, you should use Last but not least, if you want to get a Window Manager frame position, - you should use If you want to get the position of the window (including the WM + decorations), you should use + Last but not least, if you want to get a Window Manager frame + position, you should use + +Your choice of Window Manager will have an effect of the results of +the above functions. You should keep this in mind when writing your +application. This is dependant upon how the Window Managers manage the +decorations that they add around windows. + How do I set the size of a widget/window? How do I prevent the user resizing my window?

@@ -1632,17 +1686,17 @@ The -void gtk_widget_set_usize (GtkWidget *widget, - gint width, - gint height); - -void gtk_window_set_policy (GtkWindow *window, - gint allow_shrink, - gint allow_grow, - gint auto_shrink); +void gtk_widget_set_usize (GtkWidget *widget, + gint width, + gint height); + +void gtk_window_set_policy (GtkWindow *window, + gint allow_shrink, + gint allow_grow, + gint auto_shrink); +The window, + x_pos, y_pos, + x_size, y_size); How do I add a popup menu to my GTK+ application?

@@ -1694,8 +1762,8 @@ is a boolean value: when this value is TRUE, the widget is enabled.

For example: -gint gtk_clist_prepend (GtkCList *clist, - gchar *text[]); +gint gtk_clist_prepend (GtkCList *clist, + gchar *text[]); Answer: No, while a type "gchar*" (pointer to char) can automatically @@ -1730,6 +1798,34 @@ DirectMedia Layer library (SDL). You do NOT want to use +How do I create a pixmap without having my window realized/shown? +

+Functions such as + char *pixfile = "foo.xpm"; + GtkWidget *top, *box, *pixw; + GdkPixmap *pixmap, *pixmap_mask; + + top = gtk_window_new (GKT_WINDOW_TOPLEVEL); + box = gtk_hbox_new (FALSE, 4); + gtk_conainer_add (GTK_CONTAINER(top), box); + + pixmap = gdk_pixmap_colormap_create_from_xpm ( + NULL, gtk_widget_get_colormap(top), + &pixmap_mask, NULL, pixfile); + pixw = gtk_pixmap_new (pixmap, pixmap_mask); + gdk_pixmap_unref (pixmap); + gdk_pixmap_unref (pixmap_mask); + + + Development with GTK+: widget specific questions @@ -1836,6 +1932,25 @@ To get known about the selection: } + +How do I stop the column headings of a GtkCList disappearing +when the list is scrolled? +

+This happens when a GtkCList is packed into a GtkScrolledWindow using +the function + GtkWidget *scrolled, *clist; + char *titles[] = { "Title1" , "Title2" }; + + scrolled = gtk_scrolled_window_new(NULL, NULL); + + clist = gtk_clist_new_with_titles(2, titles); + gtk_container_add(GTK_CONTAINER(scrolled), clist); + +

I don't want the user of my applications to enter text into a GtkCombo. Any idea?

@@ -1956,9 +2071,9 @@ align it, center it or left align it. If you want to do this, you should use: -void gtk_misc_set_alignment (GtkMisc *misc, - gfloat xalign, - gfloat yalign); +void gtk_misc_set_alignment (GtkMisc *misc, + gfloat xalign, + gfloat yalign); where the - -How do I use horizontal scrollbars with a GtkText widget? -

-The short answer is that you can't. The current version of the GtkText -widget does not support horizontal scrolling. There is an intention to -completely rewrite the GtkText widget, at which time this limitation -will be removed. - I can't add more than (something like) 2000 chars in a GtkEntry. What's wrong?

@@ -2064,6 +2171,28 @@ the number of chars in the entry to 2047. max_length = MIN (2047, entry->text_max_length); + +How do I make a GtkEntry widget activate on pressing the Return key? +

+The Entry widget emits an 'activate' signal when you press return in +it. Just attach to the activate signal on the entry and do whatever you +want to do. Typical code would be: + + + entry = gtk_entry_new(); + gtk_signal_connect (GTK_OBJECT(entry), "activate", + GTK_SIGNAL_FUNC(entry_callback), + NULL); + + + +How do I use horizontal scrollbars with a GtkText widget? +

+The short answer is that you can't. The current version of the GtkText +widget does not support horizontal scrolling. There is an intention to +completely rewrite the GtkText widget, at which time this limitation +will be removed. + How do I change the font of a GtkText widget?

@@ -2565,45 +2694,51 @@ have not accepted "hi 7 am 17" or "hi i hi 17". GTK+ FAQ Contributions, Maintainers and Copyright

-If you would like to make a contribution to the FAQ, send either one of us -an e-mail message with the exact text you think should be included (question and -answer). With your help, this document can grow and become more useful! +If you would like to make a contribution to the FAQ, send either one +of us an e-mail message with the exact text you think should be +included (question and answer). With your help, this document can grow +and become more useful! -This document is maintained by Nathan Froyd -, +This document is maintained by Tony Gale and +name="<gale@gtk.org>"> +Nathan Froyd , +and Emmanuel Deloget . This FAQ was created by Shawn T. Amundson who continues to provide support. -The GTK+ FAQ is Copyright (C) 1997,1998, 1999 by Shawn T. Amundson, -Nathan Froyd and Tony Gale, Emmanuel Deloget. +Contributions should be sent to Tony Gale + +The GTK+ FAQ is Copyright (C) 1997-2000 by Shawn T. Amundson, +Tony Gale, Emmanuel Deloget and Nathan Froyd. -Permission is granted to make and distribute verbatim copies of -this manual provided the copyright notice and this permission notice -are preserved on all copies. +Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. -Permission is granted to copy and distribute modified versions of -this document under the conditions for verbatim copying, provided -that this copyright notice is included exactly as in the original, -and that the entire resulting derived work is distributed under -the terms of a permission notice identical to this one. +Permission is granted to copy and distribute modified versions of this +document under the conditions for verbatim copying, provided that this +copyright notice is included exactly as in the original, and that the +entire resulting derived work is distributed under the terms of a +permission notice identical to this one. -Permission is granted to copy and distribute translations of -this document into another language, under the above conditions -for modified versions. +Permission is granted to copy and distribute translations of this +document into another language, under the above conditions for +modified versions. -If you are intending to incorporate this document into a published work, -please contact one of the maintainers, and we will make an effort to ensure -that you have the most up to date information available. +If you are intending to incorporate this document into a published +work, please contact one of the maintainers, and we will make an +effort to ensure that you have the most up to date information +available. There is no guarentee that this document lives up to its intended -purpose. This is simply provided as a free resource. As such, -the authors and maintainers of the information provided within can -not make any guarentee that the information is even accurate. +purpose. This is simply provided as a free resource. As such, the +authors and maintainers of the information provided within can not +make any guarentee that the information is even accurate. -- 2.30.2